package cv.gzd.robot.service.impl;

import cv.gzd.common.utils.Page;
import cv.gzd.robot.mapper.DevDao;
import cv.gzd.robot.pojo.Dev;
import cv.gzd.robot.pojo.vo.DevQueryVo;
import cv.gzd.robot.service.DevService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: Jun
 * @Date: 2018/8/16 14:24
 */
@Service
public class DevServiceImpl implements DevService {
    @Autowired
    DevDao devDao;
    @Override
    public Page<Dev> selectPageByDevQueryVo(DevQueryVo devVo) {
        Page<Dev> page=new Page<>();
        page.setSize(5);
        if(devVo!=null){
            devVo.setSize(5);
            if(devVo.getPage()!=null){
                page.setPage(devVo.getPage());
                devVo.setStartRow((devVo.getPage()-1)*devVo.getSize());
            }
            if(devVo.getQueryType()!=null){
                if(devVo.getRobotValue()!=null&&!"".equals(devVo.getRobotValue().trim())){
                    devVo.setRobotValue(devVo.getRobotValue().trim());
                }
            }
            page.setTotal(devDao.selectDevCountByDevQueryVo(devVo));
            page.setRows(devDao.selectDevListByDevQueryVo(devVo));
        }
        return page;
    }

    @Override
    public Dev selectDevByRiv(Integer id) {
        return devDao.selectDevByRid(id);
    }

    @Override
    public void updateDev(Dev dev) {
        devDao.updateDev(dev);
    }

    @Override
    public void deleteDev(Integer id) {
        devDao.deleteDev(id);
    }

    @Override
    public void saveDev(Dev dev) {
        devDao.saveDev(dev);
    }
}
